const request = require('request')
const fs = require('fs')
request('http://localhost:8080/test.html', (err, responce, body) => {
  console.log('error: ', err)
  console.log('statusCode: ', responce.statusCode)
  console.log('body: ', body)
}).pipe(fs.createWriteStream('b.html'))

request.get('http://localhost:8080/test.html')
        .on('error', err => {
          console.log(err)
        })
        .pipe(fs.createWriteStream('a.html'))